#include <bits/stdc++.h>

using namespace std;

const int MOD = 998244353;
inline int Plus(int a, int b) {return a + b >= MOD ? a + b - MOD : a + b; }
inline int Minus(int a, int b) {return a - b < 0 ? a - b + MOD : a - b; }
inline int ksm(long long a, int b) {
    long long r = 1;
    for(; b; b >>= 1, a = a * a % MOD)
        if(b & 1) r = r * a % MOD;
    return r;
}

const int N = 3e6 + 10;
int n; string S;

set<string> Set;
void dfs(string S) {
    Set.insert(S);
    for(int i = 0; i + 1 < S.size(); i ++) {
        if(!(S[i] == S[i + 1] || (S[i] == 'B' && S[i + 1] == 'A'))) continue;
        string T = S;
        T.erase(T.begin() + i), T.erase(T.begin() + i);
        if(!Set.count(T)) dfs(T);
    }
}

int main() {
    freopen("song.in", "r", stdin);
    freopen("song.out", "w", stdout);
    ios::sync_with_stdio(false), cin.tie(0);

    cin >> S; n = S.size(), S = "$" + S;
    bool flag = true;
    for(int i = 1; i < n; i ++) flag = flag && (S[i] != S[i + 1]);
    if(flag) {
        int ans = 1;
        for(int i = 1; i < n; i ++)
            ans += (S[i] == 'B');
        cout << ans << '\n';
        return 0;
    }

    S.erase(S.begin());
    dfs(S);
    cout << Set.size() << '\n';

    return 0;
}